/****************************************************
    文件：Singleton.cs
    作者：fanshaohua
    日期：2022/1/13 11:24:9
    功能：单例基类
****************************************************/

namespace SgsUI
{
    public class Singleton<T> where T : class, new()
    {
        private static T instance;
        private static readonly object lockObj = new object();
        public static T Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (lockObj)
                    {
                        if (instance == null)
                        {
                            instance = new T();
                            (instance as Singleton<T>).Init();
                        }
                    }
                }
                return instance;
            }
        }

        public virtual void Init()
        {

        }
    }
}